<!--
 * @Author: 'yangyuhang1203' '2621131059@qq.com'
 * @Date: 2025-09-09 11:28:08
 * @LastEditors: 'yangyuhang1203' '2621131059@qq.com'
 * @LastEditTime: 2025-09-09 14:31:24
 * @FilePath: \企业级\前端\js\js对象\js对象-1.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Array对象</title>
</head>
<body>
    <script>
        //数组创建方式一
        var arr1 = [1,"a",true,[1,2,3],{name:"zhangsan",age:18},null];
        //数组创建方式二
        var arr2 = new Array(1,2,3,4);
        arr1[10] = 100;
        //console.log(arr1[10]);
        // 数组的遍历
        //普通for循环
        for(var i = 0;i<arr1.length;i++){
            console.log("arr[" + i + "]: " +arr1[i]);
        }
        console.log("遍历for-of循环");
        //遍历for-of循环
        for(var temp of arr1){
            console.log(temp);
        }
        console.log("foreach遍历");
        //foreach遍历
        //第一个值代表参数，第二个值表示索引
        arr1.forEach(function(a,b){
            console.log(a,b);
        });
        //箭头函数
        var fun = (a,b) =>console.log(a,b);
        arr1.forEach(fun);  
    </script>
    

</body>
</html>